import sys
from collections import Counter

def find_cell(name, myfile, number=0):
	relist = []
	with open(myfile, "r") as f:
		all_lines = f.readlines()
		
		for i in range(len(all_lines)):
			if i > number:
				if name in all_lines[i]:
					aname = all_lines[i].split(' ')[1]
					relist.append(aname)
	return Counter(relist)

def print_help():
	help_text = """\
	element1: name ( "" ~> string; Prefix Name)
	element2: myfile ( "" -> string; SPICE file path)
        element3: number ( "" -> int; start index nubmer, defult is 0)
	"""
	print(help_text)


if __name__ == "__main__" :
	try:
		name = sys.argv[1]
		spifile = sys.argv[2]
		number = sys.argv[3]

		number = int(number)
		if '-h' in sys.argv  or '--help' in sys.argv: 
			print_help()
		else:
			print(find_cell(name, spifile, number))
	except:
		print(sys.argv)
		print_help()